<?php
namespace App\Http\Controllers\Api;

use App\V3\V3_1\Models\AuthMenuModel;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;

/**
 * 权限菜单
 * Class AuthMenuController
 * @package App\Http\Controllers\Api
 */
class AuthMenuController extends BaseController
{

    public function index(){
        $model = AuthMenuModel::get();
        return $this->success($model);
    }
    /**
     * 菜单更新
     * change 在 2021/11/9 15:37 创建
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function edit(Request $request){
        //参数验证
        $validator = Validator::make($data = $request->except('role_id'), [
            'id' =>'required|integer',//主键id
            'index' =>'required|integer',//索引或下标
        ]);
        //参数错误响应
        if ($info = $validator->errors()->first()) {
            return response()->json([
                'code' => 1,
                'msg' => $info,
                'data' => '',
            ]);
        }
        AuthMenuModel::where('id',$data['id'])->update($data);
        return $this->success();
    }
}
